home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume6 / suntetrs.2 < prev    next >
Encoding:
Internet Message Format  |  1989-07-06  |  54.2 KB

  1. Path: uunet!tektronix!tekgen!tekred!games
  2. From: games@tekred.CNA.TEK.COM
  3. Newsgroups: comp.sources.games
  4. Subject: v06i043:  sun-tetris2 - tetris for SunView in colour
  5. Message-ID: <3801@tekred.CNA.TEK.COM>
  6. Date: 3 Apr 89 20:22:48 GMT
  7. Sender: billr@tekred.CNA.TEK.COM
  8. Lines: 1630
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: phill%med-image.compsci.bristol.ac.uk@nss.cs.ucl.ac.uk
  12. Posting-number: Volume 6, Issue 43
  13. Archive-name: sun-tetris2
  14.  
  15.     [The other day I received two implementations of tetris under
  16.      SunView.  This is the second one.  They both use color (colour)
  17.      on machines that support it.  I have tested them both on a B&W
  18.      Sun 3/60, SunOS 3.5. Be sure you reference the correct one
  19.      when posting comments, bugfixes, etc. -br]
  20.  
  21. #! /bin/sh
  22. # This is a shell archive.  Remove anything before this line, then unpack
  23. # it by saving it into a file and typing "sh file".  To overwrite existing
  24. # files, type "sh file -c".  You can also feed this as standard input via
  25. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  26. # will see the following message at the end:
  27. #        "End of archive 1 (of 1)."
  28. # Contents:  README MANIFEST COPYRIGHT Makefile colours.c defs.h draw.c
  29. #   event.c init.c main.c notify.c score.c shape.c support.c tetris.6
  30. #   tetris.icon window.c
  31. # Wrapped by billr@saab on Mon Apr  3 12:45:55 1989
  32. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  33. if test -f 'README' -a "${1}" != "-c" ; then 
  34.   echo shar: Will not clobber existing file \"'README'\"
  35. else
  36. echo shar: Extracting \"'README'\" \(775 characters\)
  37. sed "s/^X//" >'README' <<'END_OF_FILE'
  38. XSunview Based Tetris
  39. X
  40. XThis version of tetris is based on the version posted to
  41. Xcomp.sources.games by Adam Marguilies <vespa@ssyx.ucsc.edu> in early
  42. XMarch, 1989. We have only used the routine define_shapes() from his
  43. Xcode together with the basic shape data structure.
  44. X
  45. XThis was developed under SunOS4.01 running on a Sun3.
  46. X
  47. XTo install:
  48. X
  49. X    Set HIGH_SCORE_TABLE in defs.h to the pathname of your high
  50. X    scores table.  (If you do not want tetris to be installed setuid
  51. X    (the default) this file will have to be globally
  52. X    read/writable). The high score file will be created the first
  53. X    time tetris is executed.
  54. X
  55. X    Set BINDIR in Makefile to be the desired location of the
  56. X    compiled binary.
  57. X
  58. X    type "make install"
  59. X
  60. XPhill Everson & Martyn Shortley
  61. XBristol University, UK
  62. X
  63. X31st March, 1989
  64. END_OF_FILE
  65. if test 775 -ne `wc -c <'README'`; then
  66.     echo shar: \"'README'\" unpacked with wrong size!
  67. fi
  68. # end of 'README'
  69. fi
  70. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  71.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  72. else
  73. echo shar: Extracting \"'MANIFEST'\" \(641 characters\)
  74. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  75. X   File Name        Archive #    Description
  76. X-----------------------------------------------------------
  77. X COPYRIGHT                  1    
  78. X MANIFEST                   1    This shipping list
  79. X Makefile                   1    
  80. X README                     1    
  81. X colours.c                  1    
  82. X defs.h                     1    
  83. X draw.c                     1    
  84. X event.c                    1    
  85. X init.c                     1    
  86. X main.c                     1    
  87. X notify.c                   1    
  88. X score.c                    1    
  89. X shape.c                    1    
  90. X support.c                  1    
  91. X tetris.6                   1    
  92. X tetris.icon                1    
  93. X window.c                   1    
  94. END_OF_FILE
  95. if test 641 -ne `wc -c <'MANIFEST'`; then
  96.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  97. fi
  98. # end of 'MANIFEST'
  99. fi
  100. if test -f 'COPYRIGHT' -a "${1}" != "-c" ; then 
  101.   echo shar: Will not clobber existing file \"'COPYRIGHT'\"
  102. else
  103. echo shar: Extracting \"'COPYRIGHT'\" \(1143 characters\)
  104. sed "s/^X//" >'COPYRIGHT' <<'END_OF_FILE'
  105. XCopyright 1989 Phill Everson & Martyn Shortley
  106. X
  107. XThis notice and any statement of authorship must be reproduced
  108. Xon all copies.  The authors do not make any warranty expressed
  109. Xor implied, or assume any liability or responsiblity for the
  110. Xuse of this software.
  111. X
  112. XAny distributor of copies of this software shall grant the
  113. Xrecipient permission for further redistribution as permitted
  114. Xby this notice.  Any distributor must distribute this software
  115. Xwithout any fee or other monetary gains, unless expressed written
  116. Xpermission is granted by the authors.
  117. X
  118. XThis software or its use shall not be: sold, rented, leased,
  119. Xtraded, or otherwise marketed without the expressed written
  120. Xpermission of the authors.
  121. X
  122. XIf the software is modified in a manner creating derivative
  123. Xcopyrights, appropriate legends may be placed on derivative
  124. Xwork in addition to that set forth above.
  125. X
  126. XPermission is hereby granted to copy, reproduce, redistribute or
  127. Xotherwise use this software as long as the conditions above
  128. Xare met.
  129. X
  130. XAll rights not granted by this notice are reserved.
  131. X
  132. XAuthors: Phill Everson <everson@cs.bris.ac.uk>
  133. X         Martyn Shortley <shortley@cs.bris.ac.uk>
  134. END_OF_FILE
  135. if test 1143 -ne `wc -c <'COPYRIGHT'`; then
  136.     echo shar: \"'COPYRIGHT'\" unpacked with wrong size!
  137. fi
  138. # end of 'COPYRIGHT'
  139. fi
  140. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  141.   echo shar: Will not clobber existing file \"'Makefile'\"
  142. else
  143. echo shar: Extracting \"'Makefile'\" \(652 characters\)
  144. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  145. XBINDIR=/usr/doc1/phill/bin
  146. XCFLAGS=-O
  147. X#CFLAGS=-g
  148. X
  149. XPROG=tetris
  150. XCFILES=main.c event.c init.c shape.c support.c notify.c colours.c window.c \
  151. X        score.c draw.c
  152. XOFILES=main.o event.o init.o shape.o support.o notify.o colours.o window.o \
  153. X        score.o draw.o
  154. X
  155. X$(PROG):    $(OFILES)
  156. X    cc $(CFLAGS) -o $(PROG) $(OFILES) -lsuntool -lsunwindow -lpixrect
  157. X
  158. X$(OFILES): defs.h
  159. X
  160. X# tetris needs to be setuid so that the high scores file can be updated.
  161. X# if you don't like setuid programs on your system then just make sure
  162. X# that the high score file is globally read/writable.
  163. Xinstall: $(PROG)
  164. X    install -s $(PROG) $(BINDIR)
  165. X    chmod u+s $(BINDIR)/$(PROG)
  166. X
  167. Xclean:
  168. X    rm *.o core 
  169. END_OF_FILE
  170. if test 652 -ne `wc -c <'Makefile'`; then
  171.     echo shar: \"'Makefile'\" unpacked with wrong size!
  172. fi
  173. # end of 'Makefile'
  174. fi
  175. if test -f 'colours.c' -a "${1}" != "-c" ; then 
  176.   echo shar: Will not clobber existing file \"'colours.c'\"
  177. else
  178. echo shar: Extracting \"'colours.c'\" \(888 characters\)
  179. sed "s/^X//" >'colours.c' <<'END_OF_FILE'
  180. X#include "defs.h"
  181. X
  182. Xsetup_colours(pw)
  183. XPixrect    *pw;
  184. X{
  185. X    unsigned char    red[NO_COLS], green[NO_COLS], blue[NO_COLS];
  186. X    int        i;
  187. X
  188. X    pw_setcmsname(pw, "TETRIS");
  189. X    
  190. X    for (i=0; i < NO_COLS; i++)
  191. X        red[i] = green[i] = blue[i] = 255;
  192. X    pw_putcolormap(pw, 0, NO_COLS, red, green, blue);
  193. X
  194. X    red[WHITE]  = 255;        green[WHITE]  = 255;    blue[WHITE]  = 255;
  195. X    red[RED]    = 255;        green[RED]    =   0;    blue[RED]    =   0;
  196. X    red[ORANGE] = 255;        green[ORANGE] = 120;    blue[ORANGE] =  50;
  197. X    red[YELLOW] = 245;        green[YELLOW] = 245;    blue[YELLOW] =   0;
  198. X    red[GREEN]  =   0;        green[GREEN]  = 255;    blue[GREEN]  =   0;
  199. X    red[BLUE]   =   0;        green[BLUE]   =   0;    blue[BLUE]   = 255;
  200. X    red[CYAN]   =   0;        green[CYAN]   = 245;    blue[CYAN]   = 245;
  201. X    red[VIOLET] = 128;        green[VIOLET] =   0;    blue[VIOLET] = 178;
  202. X    red[BLACK]  =   0;        green[BLACK]  =   0;    blue[BLACK]  =   0;
  203. X
  204. X    pw_putcolormap(pw, 0, NO_COLS, red, green, blue);
  205. X}
  206. X
  207. END_OF_FILE
  208. if test 888 -ne `wc -c <'colours.c'`; then
  209.     echo shar: \"'colours.c'\" unpacked with wrong size!
  210. fi
  211. # end of 'colours.c'
  212. fi
  213. if test -f 'defs.h' -a "${1}" != "-c" ; then 
  214.   echo shar: Will not clobber existing file \"'defs.h'\"
  215. else
  216. echo shar: Extracting \"'defs.h'\" \(2314 characters\)
  217. sed "s/^X//" >'defs.h' <<'END_OF_FILE'
  218. X#include <stdio.h>
  219. X#include <sys/time.h>
  220. X#include <suntool/sunview.h>
  221. X#include <suntool/panel.h>
  222. X#include <suntool/canvas.h>
  223. X#include <sunwindow/notify.h>
  224. X#include <pixrect/pixrect_hs.h>
  225. X
  226. X#define UWIDTH          10      /* canvas size in units */
  227. X#define UHEIGHT         30
  228. X
  229. X#define UNIT            20      /* pixels in a unit */
  230. X#define SHADOW_OFFSET   UNIT
  231. X#define SHADOW_HEIGHT   (UNIT+SHADOW_OFFSET)    /* shadow area height in
  232. X                                                 * pixels */
  233. X#define NEXT_HEIGHT        (UNIT*5)    /* Height for next block */
  234. X
  235. X#define HIGH_TABLE_SIZE 10      /* size of high score table */
  236. X#ifndef HIGH_SCORE_TABLE
  237. X#    define HIGH_SCORE_TABLE    "/usr/games/lib/tetris_scores"
  238. X#endif
  239. X
  240. X#define ITIMER_NULL     ((struct itimerval *)0)
  241. X
  242. X#define       NO_COLS 16
  243. X
  244. X#define       WHITE   0
  245. X#define       RED     1
  246. X#define       ORANGE  2
  247. X#define       YELLOW  3
  248. X#define       GREEN   4
  249. X#define       BLUE    5
  250. X#define       CYAN    6
  251. X#define       VIOLET  7
  252. X#define       BLACK   8
  253. X
  254. X#define     OP        (PIX_SRC | PIX_COLOR(col))
  255. X#define     CLR        (PIX_SRC | PIX_COLOR(WHITE))
  256. X
  257. X
  258. XFrame   frame, score_frame;
  259. XPanel   panel, score_panel;
  260. XCanvas  canvas;
  261. XPixwin *pw;
  262. XPanel_item high_score_item[HIGH_TABLE_SIZE+1], score_item, level_item, rows_item, game_over;
  263. XPixrect *pr;
  264. X
  265. Xint        end_of_game, score_position;
  266. Xint     shape_no, xpos, ypos, rot, score, rows;
  267. Xint        next_no, next_rot;
  268. Xchar   *name;
  269. Xint     monochrome;
  270. Xunsigned char grid[UWIDTH][UHEIGHT];
  271. X
  272. Xstruct score_table {
  273. X        char    name[BUFSIZ];
  274. X        int     score;
  275. X        int     rows;
  276. X        int     level;
  277. X        char hostname[BUFSIZ];
  278. X        char    date[BUFSIZ];
  279. X}       high_scores[HIGH_TABLE_SIZE];
  280. X
  281. Xstruct shape_table {
  282. X        int     table[4][4];
  283. X        int     width;
  284. X        int     height;
  285. X        int     offset;
  286. X        int     pointv[4];
  287. X        char    color;
  288. X}       shape[7];
  289. X
  290. Xstruct shape {
  291. X        int     shape;
  292. X        int     rot;
  293. X        int     width;
  294. X        int     height;
  295. X        int     offset;
  296. X        int     pointv;
  297. X        char    color;
  298. X        int     was_shown;
  299. X        int     was_shadowed;
  300. X}      *current, *next;
  301. X
  302. Xint     my_client_object;
  303. XNotify_client *me;
  304. X
  305. Xvoid    print_high_scores(), done_proc(), quit_proc(), start_proc(), pause_proc(), restart_proc();
  306. Xvoid    canvas_event_proc();
  307. XNotify_value drop_block();
  308. END_OF_FILE
  309. if test 2314 -ne `wc -c <'defs.h'`; then
  310.     echo shar: \"'defs.h'\" unpacked with wrong size!
  311. fi
  312. # end of 'defs.h'
  313. fi
  314. if test -f 'draw.c' -a "${1}" != "-c" ; then 
  315.   echo shar: Will not clobber existing file \"'draw.c'\"
  316. else
  317. echo shar: Extracting \"'draw.c'\" \(4604 characters\)
  318. sed "s/^X//" >'draw.c' <<'END_OF_FILE'
  319. X#include "defs.h"
  320. X
  321. Xdraw_shadow(shape_no, xpos, ypos, rot, col)
  322. X        int     shape_no, xpos, ypos, rot, col;
  323. X{
  324. X        int     y1;
  325. X        int     x1, x2, x3, x4;
  326. X        int     t0, t1, t2, t3;
  327. X        int     xsize;
  328. X
  329. X        t0 = shape[shape_no].table[0][rot];     /* Bit map of 1st Row */
  330. X        t1 = shape[shape_no].table[1][rot];     /* Bit map of 2nd Row */
  331. X        t2 = shape[shape_no].table[2][rot];     /* Bit map of 3rd Row */
  332. X        t3 = shape[shape_no].table[3][rot];     /* Bit map of 4th Row */
  333. X
  334. X        x1 = xpos * UNIT;       /* Position of 1st column of block grid */
  335. X        x2 = x1 + UNIT;         /* Position of 2nd column of block grid */
  336. X        x3 = x2 + UNIT;         /* Position of 3rd column of block grid */
  337. X        x4 = x3 + UNIT;         /* Position of 4th column of block grid */
  338. X
  339. X        y1 = UHEIGHT * UNIT + SHADOW_OFFSET / 2;
  340. X        xsize = UWIDTH * UNIT;
  341. X
  342. X        pw_batch_on(pw);
  343. X        pw_rop(pw, 0, y1, xsize, UNIT, CLR, NULL, 0, 0);
  344. X        if (t0 & 8 || t1 & 8 || t2 & 8 || t3 & 8)
  345. X                pw_rop(pw, x1, y1, UNIT, UNIT, OP, NULL, 0, 0);
  346. X        if (t0 & 4 || t1 & 4 || t2 & 4 || t3 & 4)
  347. X                pw_rop(pw, x2, y1, UNIT, UNIT, OP, NULL, 0, 0);
  348. X        if (t0 & 2 || t1 & 2 || t2 & 2 || t3 & 2)
  349. X                pw_rop(pw, x3, y1, UNIT, UNIT, OP, NULL, 0, 0);
  350. X        if (t0 & 1 || t1 & 1 || t2 & 1 || t3 & 1)
  351. X                pw_rop(pw, x4, y1, UNIT, UNIT, OP, NULL, 0, 0);
  352. X        pw_batch_off(pw);
  353. X}
  354. X
  355. Xshow_next()
  356. X{
  357. X        int     y, y1, xsize;
  358. X
  359. X        y = UHEIGHT * UNIT + SHADOW_HEIGHT;
  360. X        xsize = UNIT * UWIDTH;
  361. X
  362. X        pw_batch_on(pw);
  363. X        pw_rop(pw, 0, y + UNIT, xsize, NEXT_HEIGHT - UNIT, CLR, NULL, 0, 0);
  364. X
  365. X        pw_text(pw, 5, y + UNIT, PIX_SRC, NULL, "Next block");
  366. X
  367. X        y1 = y / UNIT + 1;
  368. X        print_shape(next_no, 5, y1, next_rot, shape[next_no].color);
  369. X
  370. X        pw_batch_off(pw);
  371. X}
  372. X
  373. Xprint_shape(shape_no, x, y, rot, col)
  374. X        int     shape_no, x, y, rot, col;
  375. X{
  376. X        int     x1, x2, x3, x4, y1;
  377. X        int     t0, t1, t2, t3;
  378. X
  379. X        t0 = shape[shape_no].table[0][rot];     /* Bit map of 1st Row */
  380. X        t1 = shape[shape_no].table[1][rot];     /* Bit map of 2nd Row */
  381. X        t2 = shape[shape_no].table[2][rot];     /* Bit map of 3rd Row */
  382. X        t3 = shape[shape_no].table[3][rot];     /* Bit map of 4th Row */
  383. X
  384. X        x1 = x * UNIT;          /* Position of 1st column of block grid */
  385. X        x2 = x1 + UNIT;         /* Position of 2nd column of block grid */
  386. X        x3 = x2 + UNIT;         /* Position of 3rd column of block grid */
  387. X        x4 = x3 + UNIT;         /* Position of 4th column of block grid */
  388. X        y1 = y * UNIT;          /* Position of 1st row of block grid    */
  389. X
  390. X        if (y > -1) {
  391. X                if (t0 & 8)
  392. X                        pw_rop(pw, x1, y1, UNIT, UNIT, OP, NULL, 0, 0);
  393. X                if (t0 & 4)
  394. X                        pw_rop(pw, x2, y1, UNIT, UNIT, OP, NULL, 0, 0);
  395. X                if (t0 & 2)
  396. X                        pw_rop(pw, x3, y1, UNIT, UNIT, OP, NULL, 0, 0);
  397. X                if (t0 & 1)
  398. X                        pw_rop(pw, x4, y1, UNIT, UNIT, OP, NULL, 0, 0);
  399. X        }
  400. X        y1 += UNIT;             /* Position of next row */
  401. X        if (y > -2) {
  402. X                if (t1 & 8)
  403. X                        pw_rop(pw, x1, y1, UNIT, UNIT, OP, NULL, 0, 0);
  404. X                if (t1 & 4)
  405. X                        pw_rop(pw, x2, y1, UNIT, UNIT, OP, NULL, 0, 0);
  406. X                if (t1 & 2)
  407. X                        pw_rop(pw, x3, y1, UNIT, UNIT, OP, NULL, 0, 0);
  408. X                if (t1 & 1)
  409. X                        pw_rop(pw, x4, y1, UNIT, UNIT, OP, NULL, 0, 0);
  410. X        }
  411. X        y1 += UNIT;             /* Position of next row */
  412. X        if (y > -3) {
  413. X                if (t2 & 8)
  414. X                        pw_rop(pw, x1, y1, UNIT, UNIT, OP, NULL, 0, 0);
  415. X                if (t2 & 4)
  416. X                        pw_rop(pw, x2, y1, UNIT, UNIT, OP, NULL, 0, 0);
  417. X                if (t2 & 2)
  418. X                        pw_rop(pw, x3, y1, UNIT, UNIT, OP, NULL, 0, 0);
  419. X                if (t2 & 1)
  420. X                        pw_rop(pw, x4, y1, UNIT, UNIT, OP, NULL, 0, 0);
  421. X        }
  422. X        y1 += UNIT;             /* Position of next row */
  423. X        if (y > -4) {
  424. X                if (t3 & 8)
  425. X                        pw_rop(pw, x1, y1, UNIT, UNIT, OP, NULL, 0, 0);
  426. X                if (t3 & 4)
  427. X                        pw_rop(pw, x2, y1, UNIT, UNIT, OP, NULL, 0, 0);
  428. X                if (t3 & 2)
  429. X                        pw_rop(pw, x3, y1, UNIT, UNIT, OP, NULL, 0, 0);
  430. X                if (t3 & 1)
  431. X                        pw_rop(pw, x4, y1, UNIT, UNIT, OP, NULL, 0, 0);
  432. X        }
  433. X}
  434. END_OF_FILE
  435. if test 4604 -ne `wc -c <'draw.c'`; then
  436.     echo shar: \"'draw.c'\" unpacked with wrong size!
  437. fi
  438. # end of 'draw.c'
  439. fi
  440. if test -f 'event.c' -a "${1}" != "-c" ; then 
  441.   echo shar: Will not clobber existing file \"'event.c'\"
  442. else
  443. echo shar: Extracting \"'event.c'\" \(749 characters\)
  444. sed "s/^X//" >'event.c' <<'END_OF_FILE'
  445. X#include "defs.h"
  446. X
  447. Xvoid
  448. Xcanvas_event_proc(canvas, event, arg)
  449. X        Canvas  canvas;
  450. X        Event  *event;
  451. X        caddr_t arg;
  452. X{
  453. X        if (event_is_up(event))
  454. X                return;
  455. X
  456. X        switch (event_id(event)) {
  457. X        case MS_LEFT:
  458. X                if (event_shift_is_down(event))
  459. X                        anti_proc();
  460. X                else
  461. X                        left_proc();
  462. X                break;
  463. X        case MS_RIGHT:
  464. X                if (event_shift_is_down(event))
  465. X                        clock_proc();
  466. X                else
  467. X                        right_proc();
  468. X                break;
  469. X
  470. X        case MS_MIDDLE:
  471. X                if (!event_shift_is_down(event))
  472. X                        fast_proc();
  473. X                break;
  474. X        }
  475. X}
  476. END_OF_FILE
  477. if test 749 -ne `wc -c <'event.c'`; then
  478.     echo shar: \"'event.c'\" unpacked with wrong size!
  479. fi
  480. # end of 'event.c'
  481. fi
  482. if test -f 'init.c' -a "${1}" != "-c" ; then 
  483.   echo shar: Will not clobber existing file \"'init.c'\"
  484. else
  485. echo shar: Extracting \"'init.c'\" \(1670 characters\)
  486. sed "s/^X//" >'init.c' <<'END_OF_FILE'
  487. X#include "defs.h"
  488. X#include <sys/types.h>
  489. X#include <sys/timeb.h>
  490. X#include <pwd.h>
  491. X
  492. Xinitialise()
  493. X{
  494. X        struct passwd *who;
  495. X        int     depth;
  496. X        Pixrect *mem_create();
  497. X        char   *getenv();
  498. X
  499. X        srand((int) time((time_t *) 0));
  500. X        define_shapes();
  501. X        depth = pw->pw_prretained->pr_depth;
  502. X        monochrome = 0;
  503. X        if (depth == 1)
  504. X                monochrome = 1;
  505. X        if ((pr = mem_create(UNIT * UWIDTH, UNIT * UHEIGHT, depth)) == NULL) {
  506. X                fprintf(stderr, "mem_create() returned NULL\n");
  507. X                exit(-1);
  508. X        }
  509. X        if ((name = getenv("TETRIS")) == NULL) {
  510. X                who = getpwuid(getuid());
  511. X                name = who->pw_name;
  512. X        }
  513. X        print_authors();
  514. X        init_all();
  515. X        read_high_scores();
  516. X}
  517. X
  518. Xinit_all()
  519. X{
  520. X        int     i, j;
  521. X
  522. X        score_position = -1;
  523. X        end_of_game = 0;
  524. X        rows = score = shape_no = rot = xpos = ypos = 0;
  525. X        for (i = 0; i < UWIDTH; i++)
  526. X                for (j = 0; j < UHEIGHT; j++)
  527. X                        grid[i][j] = 0;
  528. X        create_shape();         /* Set up 1st shape */
  529. X        create_shape();         /* Set up next shape */
  530. X        pw_rop(pw, 0, 0, UNIT * UWIDTH, UNIT * UHEIGHT, PIX_SRC | PIX_COLOR(WHITE), NULL, 0, 0);
  531. X        pw_vector(pw, 0, UHEIGHT * UNIT, UWIDTH * UNIT, UHEIGHT * UNIT, PIX_SRC | PIX_COLOR(BLACK), 0);
  532. X        pw_vector(pw, 0, UHEIGHT * UNIT + SHADOW_HEIGHT, UWIDTH * UNIT, UHEIGHT * UNIT + SHADOW_HEIGHT, PIX_SRC | PIX_COLOR(BLACK), 0);
  533. X        panel_set(game_over, PANEL_SHOW_ITEM, FALSE, 0);
  534. X        show_score();
  535. X        show_next();
  536. X        draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
  537. X}
  538. END_OF_FILE
  539. if test 1670 -ne `wc -c <'init.c'`; then
  540.     echo shar: \"'init.c'\" unpacked with wrong size!
  541. fi
  542. # end of 'init.c'
  543. fi
  544. if test -f 'main.c' -a "${1}" != "-c" ; then 
  545.   echo shar: Will not clobber existing file \"'main.c'\"
  546. else
  547. echo shar: Extracting \"'main.c'\" \(5543 characters\)
  548. sed "s/^X//" >'main.c' <<'END_OF_FILE'
  549. X#include "defs.h"
  550. X
  551. Xstatic short icon_image[] = {
  552. X#include "tetris.icon"
  553. X};
  554. X
  555. Xmpr_static(tetris_icon, 64, 64, 1, icon_image);
  556. X
  557. Xmain(argc, argv)
  558. X        int     argc;
  559. X        char  **argv;
  560. X{
  561. X        int     i;
  562. X        Icon    icon;
  563. X
  564. X        icon = icon_create(ICON_IMAGE, &tetris_icon, 0);
  565. X        frame = window_create(NULL, FRAME,
  566. X                              FRAME_LABEL, "tetris",
  567. X                              FRAME_ICON, icon,
  568. X                              FRAME_ARGS, argc, argv,
  569. X                              0);
  570. X        panel = window_create(frame, PANEL,
  571. X                              WIN_WIDTH, UWIDTH * UNIT,
  572. X                              0);
  573. X        score_item = panel_create_item(panel, PANEL_MESSAGE,
  574. X                                       PANEL_ITEM_X, ATTR_COL(0),
  575. X                                       PANEL_ITEM_Y, ATTR_ROW(0),
  576. X                                       PANEL_LABEL_STRING, "Score: 0",
  577. X                                       0);
  578. X        level_item = panel_create_item(panel, PANEL_MESSAGE,
  579. X                                       PANEL_ITEM_X, ATTR_COL(0),
  580. X                                       PANEL_ITEM_Y, ATTR_ROW(1),
  581. X                                       PANEL_LABEL_STRING, "Level: 0",
  582. X                                       0);
  583. X        rows_item = panel_create_item(panel, PANEL_MESSAGE,
  584. X                                      PANEL_ITEM_X, ATTR_COL(0),
  585. X                                      PANEL_ITEM_Y, ATTR_ROW(2),
  586. X                                      PANEL_LABEL_STRING, "Rows : 0",
  587. X                                      0);
  588. X        game_over = panel_create_item(panel, PANEL_MESSAGE,
  589. X                                      PANEL_ITEM_X, ATTR_COL(0),
  590. X                                      PANEL_ITEM_Y, ATTR_ROW(3),
  591. X                                      PANEL_LABEL_STRING, "Game Over",
  592. X                                      PANEL_SHOW_ITEM, FALSE,
  593. X                                      0);
  594. X        panel_create_item(panel, PANEL_BUTTON,
  595. X                          PANEL_ITEM_X, ATTR_COL(13),
  596. X                          PANEL_ITEM_Y, ATTR_ROW(0),
  597. X                PANEL_LABEL_IMAGE, panel_button_image(panel, "Start", 0, 0),
  598. X                          PANEL_NOTIFY_PROC, start_proc,
  599. X                          0);
  600. X        panel_create_item(panel, PANEL_BUTTON,
  601. X                          PANEL_ITEM_X, ATTR_COL(13),
  602. X                          PANEL_ITEM_Y, ATTR_ROW(1),
  603. X                PANEL_LABEL_IMAGE, panel_button_image(panel, "Pause", 0, 0),
  604. X                          PANEL_NOTIFY_PROC, pause_proc,
  605. X                          0);
  606. X        panel_create_item(panel, PANEL_BUTTON,
  607. X                          PANEL_ITEM_X, ATTR_COL(13),
  608. X                          PANEL_ITEM_Y, ATTR_ROW(2),
  609. X             PANEL_LABEL_IMAGE, panel_button_image(panel, "New Game", 0, 0),
  610. X                          PANEL_NOTIFY_PROC, restart_proc,
  611. X                          0);
  612. X        panel_create_item(panel, PANEL_BUTTON,
  613. X                          PANEL_ITEM_X, ATTR_COL(13),
  614. X                          PANEL_ITEM_Y, ATTR_ROW(3),
  615. X               PANEL_LABEL_IMAGE, panel_button_image(panel, "Scores", 0, 0),
  616. X                          PANEL_NOTIFY_PROC, print_high_scores,
  617. X                          0);
  618. X
  619. X        panel_create_item(panel, PANEL_BUTTON,
  620. X                          PANEL_ITEM_X, ATTR_COL(13),
  621. X                          PANEL_ITEM_Y, ATTR_ROW(4),
  622. X                 PANEL_LABEL_IMAGE, panel_button_image(panel, "Quit", 0, 0),
  623. X                          PANEL_NOTIFY_PROC, quit_proc,
  624. X                          0);
  625. X        window_fit_height(panel);
  626. X        canvas = window_create(frame, CANVAS,
  627. X                               WIN_X, 0,
  628. X                               WIN_BELOW, panel,
  629. X                               WIN_WIDTH, UWIDTH * UNIT,
  630. X                   WIN_HEIGHT, UHEIGHT * UNIT + SHADOW_HEIGHT + NEXT_HEIGHT,
  631. X                               WIN_EVENT_PROC, canvas_event_proc,
  632. X                               0);
  633. X
  634. X
  635. X        pw = canvas_pixwin(canvas);
  636. X        setup_colours(pw);
  637. X        window_fit(frame);
  638. X
  639. X        initialise();
  640. X
  641. X        score_frame = window_create(frame, FRAME,
  642. X                                    WIN_SHOW, FALSE,
  643. X                                    0);
  644. X        score_panel = window_create(score_frame, PANEL,
  645. X                                    WIN_WIDTH, ATTR_COLS(80),
  646. X                                 WIN_HEIGHT, ATTR_ROWS(HIGH_TABLE_SIZE + 1),
  647. X                                    0);
  648. X        for (i = 0; i < HIGH_TABLE_SIZE + 1; i++)
  649. X                high_score_item[i] = panel_create_item(score_panel, PANEL_MESSAGE,
  650. X                                                  PANEL_ITEM_X, ATTR_COL(0),
  651. X                                                  PANEL_ITEM_Y, ATTR_ROW(i),
  652. X                                                       PANEL_LABEL_STRING, "                                                                              ",
  653. X                                                       0);
  654. X        panel_set(high_score_item[0], PANEL_LABEL_BOLD, TRUE, PANEL_LABEL_STRING, "Pos  Name             Score  Rows Lev  Machine     When", 0);
  655. X        panel_create_item(score_panel, PANEL_BUTTON,
  656. X           PANEL_LABEL_IMAGE, panel_button_image(score_panel, "done", 0, 0),
  657. X                          PANEL_NOTIFY_PROC, done_proc,
  658. X                          PANEL_ITEM_X, ATTR_COL(76),
  659. X                          PANEL_ITEM_Y, ATTR_ROW(0),
  660. X                          0);
  661. X        window_fit(score_panel);
  662. X        window_fit(score_frame);
  663. X        init_timer();
  664. X        window_main_loop(frame);
  665. X        exit(0);
  666. X}
  667. END_OF_FILE
  668. if test 5543 -ne `wc -c <'main.c'`; then
  669.     echo shar: \"'main.c'\" unpacked with wrong size!
  670. fi
  671. # end of 'main.c'
  672. fi
  673. if test -f 'notify.c' -a "${1}" != "-c" ; then 
  674.   echo shar: Will not clobber existing file \"'notify.c'\"
  675. else
  676. echo shar: Extracting \"'notify.c'\" \(3552 characters\)
  677. sed "s/^X//" >'notify.c' <<'END_OF_FILE'
  678. X#include "defs.h"
  679. X
  680. XNotify_value
  681. Xdrop_block(me, which)
  682. X        Notify_client me;
  683. X        int     which;
  684. X{
  685. X
  686. X        if (block_can_drop(shape_no, xpos, ypos, rot))
  687. X                print_shape(shape_no, xpos, ypos++, rot, WHITE);
  688. X        else {
  689. X                if (ypos < 0)
  690. X                        end_game();
  691. X                else {
  692. X                        score += shape[shape_no].pointv[rot];
  693. X                        store_shape(shape_no, xpos, ypos, rot);
  694. X                        remove_full_lines(ypos);
  695. X                        create_shape();
  696. X                        show_score();
  697. X                        show_next();
  698. X                }
  699. X        }
  700. X        print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
  701. X        draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
  702. X        return (NOTIFY_DONE);
  703. X}
  704. X
  705. Xshow_score()
  706. X{
  707. X        char    buf[BUFSIZ], buf1[BUFSIZ], buf2[BUFSIZ];
  708. X
  709. X        sprintf(buf, "Score: %d", score);
  710. X        panel_set(score_item, PANEL_LABEL_STRING, buf, 0);
  711. X        sprintf(buf1, "Level: %d", rows / 10);
  712. X        panel_set(level_item, PANEL_LABEL_STRING, buf1, 0);
  713. X        sprintf(buf2, "Rows : %d", rows);
  714. X        panel_set(rows_item, PANEL_LABEL_STRING, buf2, 0);
  715. X}
  716. X
  717. Xvoid
  718. Xquit_proc()
  719. X{
  720. X        clear_events();
  721. X        stop_timer();
  722. X        window_destroy(frame);
  723. X}
  724. X
  725. Xend_game()
  726. X{
  727. X        end_of_game = 1;
  728. X        clear_events();
  729. X        stop_timer();
  730. X        panel_set(game_over, PANEL_SHOW_ITEM, TRUE, 0);
  731. X        update_highscore_table();
  732. X        print_high_scores();
  733. X}
  734. X
  735. Xvoid
  736. Xrestart_proc()
  737. X{
  738. X        clear_events();
  739. X        stop_timer();
  740. X        init_all();
  741. X}
  742. X
  743. Xvoid
  744. Xstart_proc()
  745. X{
  746. X        if (end_of_game)
  747. X                return;
  748. X        set_events();
  749. X        start_timer();
  750. X}
  751. X
  752. Xvoid
  753. Xpause_proc()
  754. X{
  755. X        clear_events();
  756. X        stop_timer();
  757. X}
  758. X
  759. Xleft_proc()
  760. X{
  761. X        if (block_can_left(shape_no, xpos, ypos, rot)) {
  762. X                print_shape(shape_no, xpos, ypos, rot, WHITE);
  763. X                xpos--;
  764. X                print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
  765. X                draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
  766. X        }
  767. X}
  768. X
  769. Xright_proc()
  770. X{
  771. X        if (block_can_right(shape_no, xpos, ypos, rot)) {
  772. X                print_shape(shape_no, xpos, ypos, rot, WHITE);
  773. X                xpos++;
  774. X                print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
  775. X                draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
  776. X        }
  777. X}
  778. X
  779. Xanti_proc()
  780. X{
  781. X        int     newrot;
  782. X
  783. X        newrot = (rot + 3) % 4;
  784. X        if (check_rot(shape_no, xpos, ypos, newrot)) {
  785. X                print_shape(shape_no, xpos, ypos, rot, WHITE);
  786. X                rot = newrot;
  787. X                print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
  788. X                draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
  789. X        }
  790. X}
  791. X
  792. Xclock_proc()
  793. X{
  794. X        int     newrot;
  795. X
  796. X        newrot = (rot + 1) % 4;
  797. X        if (check_rot(shape_no, xpos, ypos, newrot)) {
  798. X                print_shape(shape_no, xpos, ypos, rot, WHITE);
  799. X                rot = newrot;
  800. X                print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
  801. X                draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
  802. X        }
  803. X}
  804. X
  805. Xfast_proc()
  806. X{
  807. X        while (block_can_drop(shape_no, xpos, ypos, rot)) {
  808. X                print_shape(shape_no, xpos, ypos, rot, WHITE);
  809. X                ypos++;
  810. X                print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
  811. X        }
  812. X}
  813. X
  814. Xvoid
  815. Xdone_proc()
  816. X{
  817. X        window_set(score_frame, WIN_SHOW, FALSE, 0);
  818. X}
  819. END_OF_FILE
  820. if test 3552 -ne `wc -c <'notify.c'`; then
  821.     echo shar: \"'notify.c'\" unpacked with wrong size!
  822. fi
  823. # end of 'notify.c'
  824. fi
  825. if test -f 'score.c' -a "${1}" != "-c" ; then 
  826.   echo shar: Will not clobber existing file \"'score.c'\"
  827. else
  828. echo shar: Extracting \"'score.c'\" \(5207 characters\)
  829. sed "s/^X//" >'score.c' <<'END_OF_FILE'
  830. X#include "defs.h"
  831. X
  832. Xupdate_highscore_table()
  833. X{
  834. X        int     i, j;
  835. X        long    when;
  836. X        extern char *ctime();
  837. X        extern long time();
  838. X        char    hostname[20];
  839. X        char    buf[BUFSIZ];
  840. X
  841. X        /* re-read high-score table in case someone else on the network is
  842. X         * playing at the same time */
  843. X        read_high_scores();
  844. X
  845. X        /* Next line finds score greater than current one */
  846. X        for (i = 0; ((i < HIGH_TABLE_SIZE) && (score >= high_scores[i].score)); i++);
  847. X        i--;
  848. X        score_position = i;
  849. X        if (i >= 0) {
  850. X                for (j = 0; j < i; j++)
  851. X                        high_scores[j] = high_scores[j + 1];
  852. X                strcpy(high_scores[i].name, name);
  853. X                high_scores[i].score = score;
  854. X                high_scores[i].rows = rows;
  855. X                high_scores[i].level = rows / 10;
  856. X                if (gethostname(hostname, BUFSIZ) == -1)
  857. X                        strcpy(high_scores[i].hostname, "unknown-host");
  858. X                else
  859. X                        strcpy(high_scores[i].hostname, hostname);
  860. X                time(&when);
  861. X                strcpy(buf, ctime(&when));      /* ctime() adds a newline
  862. X                                                 * char */
  863. X                strip_eoln(buf);/* so remove it          */
  864. X                strcpy(high_scores[i].date, buf);
  865. X                write_high_scores();
  866. X        }
  867. X}
  868. X
  869. Xread_high_scores()
  870. X{
  871. X        FILE   *fp;
  872. X        int     i;
  873. X        char   *c, buf[BUFSIZ];
  874. X
  875. X        for (i = 0; i < HIGH_TABLE_SIZE; i++) {
  876. X                strcpy(high_scores[i].name, " ");
  877. X                high_scores[i].score = 0;
  878. X                high_scores[i].rows = 0;
  879. X                high_scores[i].level = 0;
  880. X                strcpy(high_scores[i].hostname, " ");
  881. X                strcpy(high_scores[i].date, " ");
  882. X        }
  883. X        if ((fp = fopen(HIGH_SCORE_TABLE, "r")) == NULL) {
  884. X                fprintf(stderr, "tetris: No High score file\n");
  885. X                return;
  886. X        }
  887. X        for (i = 0; i < HIGH_TABLE_SIZE; i++) {
  888. X                fgets(buf, BUFSIZ, fp);
  889. X                strip_eoln(buf);
  890. X                strcpy(high_scores[i].name, buf);
  891. X                fgets(buf, BUFSIZ, fp);
  892. X                strip_eoln(buf);
  893. X                high_scores[i].score = atoi(buf);
  894. X                fgets(buf, BUFSIZ, fp);
  895. X                strip_eoln(buf);
  896. X                high_scores[i].rows = atoi(buf);
  897. X                fgets(buf, BUFSIZ, fp);
  898. X                strip_eoln(buf);
  899. X                high_scores[i].level = atoi(buf);
  900. X                fgets(buf, BUFSIZ, fp);
  901. X                strip_eoln(buf);
  902. X                strcpy(high_scores[i].hostname, buf);
  903. X                fgets(buf, BUFSIZ, fp);
  904. X                strip_eoln(buf);
  905. X                strcpy(high_scores[i].date, buf);
  906. X        }
  907. X        fclose(fp);
  908. X}
  909. X
  910. Xstrip_eoln(s)
  911. X        char   *s;
  912. X{
  913. X        char   *s1;
  914. X
  915. X        while (*s != '\0') {
  916. X                if (*s == '\n') {       /* End of line char */
  917. X                        s1 = s;
  918. X                        do {
  919. X                                *s1 = *(s1 + 1);        /* Copy rest of string */
  920. X                                s1++;
  921. X                        } while (*s1 != '\0');
  922. X                } else
  923. X                        s++;
  924. X        }
  925. X}
  926. X
  927. Xwrite_high_scores()
  928. X{
  929. X        FILE   *fp;
  930. X        int     i;
  931. X
  932. X        if ((fp = fopen(HIGH_SCORE_TABLE, "w")) == NULL) {
  933. X                fprintf(stderr, "tetris: Couldn't open high score file %s\n", HIGH_SCORE_TABLE);
  934. X                return;
  935. X        }
  936. X        for (i = 0; i < HIGH_TABLE_SIZE; i++)
  937. X                fprintf(fp, "%s\n%d\n%d\n%d\n%s\n%s\n",
  938. X                        high_scores[i].name,
  939. X                        high_scores[i].score,
  940. X                        high_scores[i].rows,
  941. X                        high_scores[i].level,
  942. X                        high_scores[i].hostname,
  943. X                        high_scores[i].date);
  944. X        fclose(fp);
  945. X}
  946. X
  947. Xvoid
  948. Xprint_high_scores()
  949. X{
  950. X        int     i;
  951. X        char    buf[BUFSIZ];
  952. X
  953. X        /* re-read high-score table in case someone else on the network is
  954. X         * playing at the same time */
  955. X        read_high_scores();
  956. X
  957. X        for (i = HIGH_TABLE_SIZE - 1; i >= 0; i--) {
  958. X                sprintf(buf, "%3d) %-15s %6d %5d %3d  %-10s  %s\n",
  959. X                        HIGH_TABLE_SIZE - i,
  960. X                        high_scores[i].name,
  961. X                        high_scores[i].score,
  962. X                        high_scores[i].rows,
  963. X                        high_scores[i].level,
  964. X                        high_scores[i].hostname,
  965. X                        high_scores[i].date);
  966. X                panel_set(high_score_item[HIGH_TABLE_SIZE - i], PANEL_LABEL_BOLD, FALSE, PANEL_LABEL_STRING, buf, 0);
  967. X        }
  968. X        if (score_position != -1)
  969. X                panel_set(high_score_item[HIGH_TABLE_SIZE - score_position], PANEL_LABEL_BOLD, TRUE, 0);
  970. X        window_set(score_frame, WIN_SHOW, TRUE, 0);
  971. X}
  972. X
  973. Xprint_authors()
  974. X{
  975. X        printf("This version of tetris was written by Phill Everson <everson@cs.bris.ac.uk>\nand Martyn Shortley <shortley@cs.bris.ac.uk>, ");
  976. X        printf("Based on the version posted\nto comp.sources.games by Adam Marguilies <vespa@ssyx.ucsc.edu>\n\nLet us know if you like it.\n31st March 1989 \n");
  977. X}
  978. END_OF_FILE
  979. if test 5207 -ne `wc -c <'score.c'`; then
  980.     echo shar: \"'score.c'\" unpacked with wrong size!
  981. fi
  982. # end of 'score.c'
  983. fi
  984. if test -f 'shape.c' -a "${1}" != "-c" ; then 
  985.   echo shar: Will not clobber existing file \"'shape.c'\"
  986. else
  987. echo shar: Extracting \"'shape.c'\" \(7330 characters\)
  988. sed "s/^X//" >'shape.c' <<'END_OF_FILE'
  989. X#include "defs.h"
  990. X
  991. Xvoid define_shapes()
  992. X{
  993. X
  994. X    /* begin shape 0 definition, four rotations */
  995. X
  996. X    shape[0].table[0][0] = 0;  
  997. X    shape[0].table[1][0] = 15;  /* #### */
  998. X    shape[0].table[2][0] = 0; 
  999. X    shape[0].table[3][0] = 0; 
  1000. X    shape[0].pointv[0] = 5; 
  1001. X
  1002. X    shape[0].table[0][1] = 4;   /*  #   */
  1003. X    shape[0].table[1][1] = 4;   /*  #   */
  1004. X    shape[0].table[2][1] = 4;   /*  #   */
  1005. X    shape[0].table[3][1] = 4;   /*  #   */
  1006. X    shape[0].pointv[1] = 8; 
  1007. X
  1008. X    shape[0].table[0][2] = 0; 
  1009. X    shape[0].table[1][2] = 15; /* #### */
  1010. X    shape[0].table[2][2] = 0; 
  1011. X    shape[0].table[3][2] = 0; 
  1012. X    shape[0].pointv[2] = 5; 
  1013. X
  1014. X    shape[0].table[0][3] = 4;   /*  #    */
  1015. X    shape[0].table[1][3] = 4;   /*  #    */
  1016. X    shape[0].table[2][3] = 4;   /*  #    */
  1017. X    shape[0].table[3][3] = 4;   /*  #    */
  1018. X    shape[0].pointv[2] = 8; 
  1019. X
  1020. X    shape[0].width = 4; 
  1021. X    shape[0].height = 1; 
  1022. X    shape[0].offset = 153;
  1023. X    shape[0].color = RED;
  1024. X
  1025. X    /* begin shape 1 definition, four rotations */
  1026. X
  1027. X    shape[1].table[0][0] = 12;  /* ##   */
  1028. X    shape[1].table[1][0] = 12;  /* ##   */
  1029. X    shape[1].table[2][0] = 0;   /*      */
  1030. X    shape[1].table[3][0] = 0;   /*      */
  1031. X    shape[1].pointv[0] = 6; 
  1032. X
  1033. X    shape[1].table[0][1] = 12;  /* ##   */
  1034. X    shape[1].table[1][1] = 12;  /* ##   */
  1035. X    shape[1].table[2][1] = 0;   /*      */
  1036. X    shape[1].table[3][1] = 0;   /*      */
  1037. X    shape[1].pointv[1] = 6; 
  1038. X
  1039. X    shape[1].table[0][2] = 12;  /* ##   */
  1040. X    shape[1].table[1][2] = 12;  /* ##   */
  1041. X    shape[1].table[2][2] = 0;   /*      */
  1042. X    shape[1].table[3][2] = 0;   /*      */
  1043. X    shape[1].pointv[2] = 6; 
  1044. X
  1045. X    shape[1].table[0][3] = 12;  /* ##   */
  1046. X    shape[1].table[1][3] = 12;  /* ##   */
  1047. X    shape[1].table[2][3] = 0;   /*      */
  1048. X    shape[1].table[3][3] = 0;   /*      */
  1049. X    shape[1].pointv[3] = 6; 
  1050. X
  1051. X    shape[1].width = 2; 
  1052. X    shape[1].height = 2; 
  1053. X    shape[1].offset = 0;
  1054. X    shape[1].color = ORANGE;
  1055. X
  1056. X    /* begin shape 2 definition, four rotations */
  1057. X
  1058. X    shape[2].table[0][0] = 4;  /*  #  */
  1059. X    shape[2].table[1][0] = 14; /* ### */
  1060. X    shape[2].table[2][0] = 0;  /*     */
  1061. X    shape[2].table[3][0] = 0;  /*     */
  1062. X    shape[2].pointv[0] = 5; 
  1063. X
  1064. X    shape[2].table[0][1] = 4;  /*  #  */
  1065. X    shape[2].table[1][1] = 6;  /*  ## */
  1066. X    shape[2].table[2][1] = 4;  /*  #  */
  1067. X    shape[2].table[3][1] = 0;  /*     */
  1068. X    shape[2].pointv[0] = 5; 
  1069. X
  1070. X    shape[2].table[0][2] = 0;  /*     */
  1071. X    shape[2].table[1][2] = 14; /* ### */
  1072. X    shape[2].table[2][2] = 4;  /*  #  */
  1073. X    shape[2].table[3][2] = 0;  /*     */
  1074. X    shape[2].pointv[2] = 6; 
  1075. X
  1076. X    shape[2].table[0][3] = 4;  /*  #  */
  1077. X    shape[2].table[1][3] = 12; /* ##  */
  1078. X    shape[2].table[2][3] = 4;  /*  #  */
  1079. X    shape[2].table[3][3] = 0;  /*     */
  1080. X    shape[2].pointv[3] = 5; 
  1081. X
  1082. X    shape[2].width = 3; 
  1083. X    shape[2].height = 2; 
  1084. X    shape[2].offset = 24;
  1085. X    shape[2].color = YELLOW;
  1086. X
  1087. X    /* begin shape 3 definition, four rotations */
  1088. X
  1089. X    shape[3].table[0][0] = 12; /* ##  */
  1090. X    shape[3].table[1][0] = 6;  /*  ## */
  1091. X    shape[3].table[2][0] = 0;  /*     */
  1092. X    shape[3].table[3][0] = 0;  /*     */
  1093. X    shape[3].pointv[0] = 6; 
  1094. X
  1095. X    shape[3].table[0][1] = 4;  /*  #  */
  1096. X    shape[3].table[1][1] = 12; /* ##  */
  1097. X    shape[3].table[2][1] = 8;  /* #   */
  1098. X    shape[3].table[3][1] = 0;  /*     */
  1099. X    shape[3].pointv[1] = 7; 
  1100. X
  1101. X    shape[3].table[0][2] = 12; /* ##  */
  1102. X    shape[3].table[1][2] = 6;  /*  ## */
  1103. X    shape[3].table[2][2] = 0;  /*     */
  1104. X    shape[3].table[3][2] = 0;  /*     */
  1105. X    shape[3].pointv[2] = 6; 
  1106. X
  1107. X    shape[3].table[0][3] = 4;  /*  #  */
  1108. X    shape[3].table[1][3] = 12; /* ##  */
  1109. X    shape[3].table[2][3] = 8;  /* #   */
  1110. X    shape[3].table[3][3] = 0;  /*     */
  1111. X    shape[3].pointv[3] = 7; 
  1112. X
  1113. X    shape[3].width = 3; 
  1114. X    shape[3].height = 2; 
  1115. X    shape[3].offset = 0;
  1116. X    shape[3].color = GREEN;
  1117. X
  1118. X    /* begin shape 4 definition, four rotations */
  1119. X
  1120. X    shape[4].table[0][0] = 6;  /*  ## */
  1121. X    shape[4].table[1][0] = 12; /* ##  */
  1122. X    shape[4].table[2][0] = 0;  /*     */
  1123. X    shape[4].table[3][0] = 0;  /*     */
  1124. X    shape[4].pointv[0] = 6; 
  1125. X
  1126. X    shape[4].table[0][1] = 8;  /* #   */
  1127. X    shape[4].table[1][1] = 12; /* ##  */
  1128. X    shape[4].table[2][1] = 4;  /*  #  */
  1129. X    shape[4].table[3][1] = 0;  /*     */
  1130. X    shape[4].pointv[1] = 7; 
  1131. X
  1132. X    shape[4].table[0][2] = 6;  /*  ## */
  1133. X    shape[4].table[1][2] = 12; /* ##  */
  1134. X    shape[4].table[2][2] = 0;  /*     */
  1135. X    shape[4].table[3][2] = 0;  /*     */
  1136. X    shape[4].pointv[2] = 6; 
  1137. X
  1138. X    shape[4].table[0][3] = 8;  /* #   */
  1139. X    shape[4].table[1][3] = 12; /* ##  */
  1140. X    shape[4].table[2][3] = 4;  /*  #  */
  1141. X    shape[4].table[3][3] = 0;  /*     */
  1142. X    shape[4].pointv[3] = 7; 
  1143. X
  1144. X    shape[4].width = 3; 
  1145. X    shape[4].height = 2; 
  1146. X    shape[4].offset = 0;
  1147. X    shape[4].color = BLUE;
  1148. X
  1149. X    /* begin shape 5 definition, four rotations */
  1150. X
  1151. X    shape[5].table[0][0] = 2;  /*   # */
  1152. X    shape[5].table[1][0] = 14; /* ### */
  1153. X    shape[5].table[2][0] = 0;  /*     */
  1154. X    shape[5].table[3][0] = 0;  /*     */
  1155. X    shape[5].pointv[0] = 6; 
  1156. X
  1157. X    shape[5].table[0][1] = 8;  /* #   */
  1158. X    shape[5].table[1][1] = 8;  /* #   */
  1159. X    shape[5].table[2][1] = 12; /* ##  */
  1160. X    shape[5].table[3][1] = 0;  /*     */
  1161. X    shape[5].pointv[1] = 7; 
  1162. X
  1163. X    shape[5].table[0][2] = 14; /* ### */
  1164. X    shape[5].table[1][2] = 8;  /* #   */
  1165. X    shape[5].table[2][2] = 0;  /*     */
  1166. X    shape[5].table[3][2] = 0;  /*     */
  1167. X    shape[5].pointv[2] = 6; 
  1168. X
  1169. X    shape[5].table[0][3] = 12; /* ##  */
  1170. X    shape[5].table[1][3] = 4;  /*  #  */
  1171. X    shape[5].table[2][3] = 4;  /*  #  */
  1172. X    shape[5].table[3][3] = 0;  /*     */
  1173. X    shape[5].pointv[3] = 7; 
  1174. X
  1175. X    shape[5].width = 3; 
  1176. X    shape[5].height = 2; 
  1177. X    shape[5].offset = 0;
  1178. X    shape[5].color = CYAN;
  1179. X
  1180. X    /* begin shape 6 definition, four rotations */
  1181. X
  1182. X    shape[6].table[0][0] = 14; /* ### */
  1183. X    shape[6].table[1][0] = 2;  /*   # */
  1184. X    shape[6].table[2][0] = 0;  /*     */
  1185. X    shape[6].table[3][0] = 0;  /*     */
  1186. X    shape[6].pointv[0] = 6; 
  1187. X
  1188. X    shape[6].table[0][1] = 4;  /*  #  */
  1189. X    shape[6].table[1][1] = 4;  /*  #  */
  1190. X    shape[6].table[2][1] = 12; /* ##  */
  1191. X    shape[6].table[3][1] = 0;  /*     */
  1192. X    shape[6].pointv[1] = 7; 
  1193. X
  1194. X    shape[6].table[0][2] = 8;  /* #   */
  1195. X    shape[6].table[1][2] = 14; /* ### */
  1196. X    shape[6].table[2][2] = 0;  /*     */
  1197. X    shape[6].table[3][2] = 0;  /*     */
  1198. X    shape[6].pointv[2] = 6; 
  1199. X
  1200. X    shape[6].table[0][3] = 12; /* ##  */
  1201. X    shape[6].table[1][3] = 8;  /* #   */
  1202. X    shape[6].table[2][3] = 8;  /* #   */
  1203. X    shape[6].table[3][3] = 0;  /*     */
  1204. X    shape[6].pointv[3] = 7; 
  1205. X
  1206. X    shape[6].width = 3; 
  1207. X    shape[6].height = 2; 
  1208. X    shape[6].offset = 0;
  1209. X    shape[6].color = VIOLET;
  1210. X}
  1211. X
  1212. Xstore_shape(shape_no, xpos, ypos, rot)
  1213. X        int     shape_no, xpos, ypos, rot;
  1214. X{
  1215. X        int     i;
  1216. X
  1217. X        for (i = 0; i < 4; i++) {
  1218. X                if (shape[shape_no].table[i][rot] & 8)
  1219. X                        grid[xpos][ypos + i] = 1;
  1220. X                if (shape[shape_no].table[i][rot] & 4)
  1221. X                        grid[xpos + 1][ypos + i] = 1;
  1222. X                if (shape[shape_no].table[i][rot] & 2)
  1223. X                        grid[xpos + 2][ypos + i] = 1;
  1224. X                if (shape[shape_no].table[i][rot] & 1)
  1225. X                        grid[xpos + 3][ypos + i] = 1;
  1226. X        }
  1227. X}
  1228. X
  1229. Xcreate_shape()
  1230. X{
  1231. X        shape_no = next_no;
  1232. X        rot = next_rot;
  1233. X        next_no = rand() % 7;
  1234. X        next_rot = rand() % 4;
  1235. X        xpos = (UWIDTH / 2) - 1;
  1236. X        ypos = -4;
  1237. X}
  1238. X
  1239. END_OF_FILE
  1240. if test 7330 -ne `wc -c <'shape.c'`; then
  1241.     echo shar: \"'shape.c'\" unpacked with wrong size!
  1242. fi
  1243. # end of 'shape.c'
  1244. fi
  1245. if test -f 'support.c' -a "${1}" != "-c" ; then 
  1246.   echo shar: Will not clobber existing file \"'support.c'\"
  1247. else
  1248. echo shar: Extracting \"'support.c'\" \(7000 characters\)
  1249. sed "s/^X//" >'support.c' <<'END_OF_FILE'
  1250. X#include "defs.h"
  1251. X
  1252. Xblock_can_drop(shape_no, xpos, ypos, rot)
  1253. X        int     shape_no, xpos, ypos, rot;
  1254. X{
  1255. X        int     y1, c;
  1256. X
  1257. X        c = 3;
  1258. X
  1259. X        while ((c >= 0) && ((shape[shape_no].table[c][rot] & 8) == 0))
  1260. X                c--;
  1261. X        y1 = ypos + c + 1;
  1262. X        if ((c != -1) && (y1 >= 0))
  1263. X                if ((y1 == UHEIGHT) || (grid[xpos][y1] != 0))
  1264. X                        return (FALSE);
  1265. X
  1266. X        c = 3;
  1267. X        while ((c >= 0) && ((shape[shape_no].table[c][rot] & 4) == 0))
  1268. X                c--;
  1269. X        y1 = ypos + c + 1;
  1270. X        if ((c != -1) && (y1 >= 0))
  1271. X                if ((y1 == UHEIGHT) || (grid[xpos + 1][y1] != 0))
  1272. X                        return (FALSE);
  1273. X
  1274. X        c = 3;
  1275. X        while ((c >= 0) && ((shape[shape_no].table[c][rot] & 2) == 0))
  1276. X                c--;
  1277. X        y1 = ypos + c + 1;
  1278. X        if ((c != -1) && (y1 >= 0))
  1279. X                if ((y1 == UHEIGHT) || (grid[xpos + 2][y1] != 0))
  1280. X                        return (FALSE);
  1281. X
  1282. X        c = 3;
  1283. X        while ((c >= 0) && ((shape[shape_no].table[c][rot] & 1) == 0))
  1284. X                c--;
  1285. X        y1 = ypos + c + 1;
  1286. X        if ((c != -1) && (y1 >= 0))
  1287. X                if ((y1 == UHEIGHT) || (grid[xpos + 3][y1] != 0))
  1288. X                        return (FALSE);
  1289. X
  1290. X        return TRUE;
  1291. X}
  1292. X
  1293. Xblock_can_left(shape_no, xpos, ypos, rot)
  1294. X        int     shape_no, xpos, ypos, rot;
  1295. X{
  1296. X        int     x1, c;
  1297. X        int     y0, y1, y2, y3;
  1298. X        int     t0, t1, t2, t3;
  1299. X
  1300. X        t0 = shape[shape_no].table[0][rot];     /* Bit map of 1st Row */
  1301. X        t1 = shape[shape_no].table[1][rot];     /* Bit map of 2nd Row */
  1302. X        t2 = shape[shape_no].table[2][rot];     /* Bit map of 3rd Row */
  1303. X        t3 = shape[shape_no].table[3][rot];     /* Bit map of 4th Row */
  1304. X
  1305. X        y0 = ypos;
  1306. X        y1 = ypos + 1;
  1307. X        y2 = ypos + 2;
  1308. X        y3 = ypos + 3;
  1309. X
  1310. X        c = 3;
  1311. X        while ((c >= 0) && ((t0 & (1 << c)) == 0))
  1312. X                c--;
  1313. X        x1 = xpos - 1 + (3 - c);
  1314. X        if (c != -1)
  1315. X                if ((x1 < 0) || ((y0 >= 0) && (grid[x1][y0] != 0)))
  1316. X                        return (FALSE);
  1317. X
  1318. X        c = 3;
  1319. X        while ((c >= 0) && ((t1 & (1 << c)) == 0))
  1320. X                c--;
  1321. X        x1 = xpos - 1 + (3 - c);
  1322. X        if (c != -1)
  1323. X                if ((x1 < 0) || ((y1 >= 0) && (grid[x1][y1] != 0)))
  1324. X                        return (FALSE);
  1325. X
  1326. X        c = 3;
  1327. X        while ((c >= 0) && ((t2 & (1 << c)) == 0))
  1328. X                c--;
  1329. X        x1 = xpos - 1 + (3 - c);
  1330. X        if (c != -1)
  1331. X                if ((x1 < 0) || ((y2 >= 0) && (grid[x1][y2] != 0)))
  1332. X                        return (FALSE);
  1333. X
  1334. X        c = 3;
  1335. X        while ((c >= 0) && ((t3 & (1 << c)) == 0))
  1336. X                c--;
  1337. X        x1 = xpos - 1 + (3 - c);
  1338. X        if (c != -1)
  1339. X                if ((x1 < 0) || ((y3 >= 0) && (grid[x1][y3] != 0)))
  1340. X                        return (FALSE);
  1341. X
  1342. X        return TRUE;
  1343. X}
  1344. X
  1345. Xblock_can_right(shape_no, xpos, ypos, rot)
  1346. X        int     shape_no, xpos, ypos, rot;
  1347. X{
  1348. X        int     x1, c;
  1349. X        int     y0, y1, y2, y3;
  1350. X        int     t0, t1, t2, t3;
  1351. X
  1352. X        t0 = shape[shape_no].table[0][rot];     /* Bit map of 1st Row */
  1353. X        t1 = shape[shape_no].table[1][rot];     /* Bit map of 2nd Row */
  1354. X        t2 = shape[shape_no].table[2][rot];     /* Bit map of 3rd Row */
  1355. X        t3 = shape[shape_no].table[3][rot];     /* Bit map of 4th Row */
  1356. X
  1357. X        y0 = ypos;
  1358. X        y1 = ypos + 1;
  1359. X        y2 = ypos + 2;
  1360. X        y3 = ypos + 3;
  1361. X
  1362. X        c = 0;
  1363. X        while ((c < 4) && ((t0 & (1 << c)) == 0))
  1364. X                c++;
  1365. X        x1 = xpos + 1 + (3 - c);
  1366. X        if ((c != 4) && (x1 >= 0))
  1367. X                if ((x1 == UWIDTH) || ((y0 >= 0) && (grid[x1][y0] != 0)))
  1368. X                        return (FALSE);
  1369. X
  1370. X        c = 0;
  1371. X        while ((c < 4) && ((t1 & (1 << c)) == 0))
  1372. X                c++;
  1373. X        x1 = xpos + 1 + (3 - c);
  1374. X        if ((c != 4) && (x1 >= 0))
  1375. X                if ((x1 == UWIDTH) || ((y1 >= 0) && (grid[x1][y1] != 0)))
  1376. X                        return (FALSE);
  1377. X
  1378. X        c = 0;
  1379. X        while ((c < 4) && ((t2 & (1 << c)) == 0))
  1380. X                c++;
  1381. X        x1 = xpos + 1 + (3 - c);
  1382. X        if ((c != 4) && (x1 >= 0))
  1383. X                if ((x1 == UWIDTH) || ((y2 >= 0) && (grid[x1][y2] != 0)))
  1384. X                        return (FALSE);
  1385. X
  1386. X        c = 0;
  1387. X        while ((c < 4) && ((t3 & (1 << c)) == 0))
  1388. X                c++;
  1389. X        x1 = xpos + 1 + (3 - c);
  1390. X        if ((c != 4) && (x1 >= 0))
  1391. X                if ((x1 == UWIDTH) || ((y3 >= 0) && (grid[x1][y3] != 0)))
  1392. X                        return (FALSE);
  1393. X
  1394. X        return TRUE;
  1395. X}
  1396. X
  1397. Xremove_full_lines(y)
  1398. X        int     y;
  1399. X{
  1400. X        int     y1, y2, full_flag, x;
  1401. X        int     xsize, ysize;
  1402. X
  1403. X        xsize = UNIT * UWIDTH;
  1404. X        pw_batch_on(pw);
  1405. X        for (y1 = y; y1 < y + 4 && y1 < UHEIGHT; y1++) {
  1406. X                full_flag = TRUE;
  1407. X                for (x = 0; x < UWIDTH; x++)
  1408. X                        if (grid[x][y1] == 0) {
  1409. X                                full_flag = FALSE;
  1410. X                                break;
  1411. X                        }
  1412. X                if (full_flag) {
  1413. X                        ysize = y1 * UNIT;
  1414. X                        for (y2 = y1; y2 > 0; y2--)
  1415. X                                for (x = 0; x < UWIDTH; x++)
  1416. X                                        grid[x][y2] = grid[x][y2 - 1];
  1417. X                        for (x = 0; x < UWIDTH; x++)
  1418. X                                grid[x][0] = 0;
  1419. X                        pr_rop(pr, 0, 0, xsize, ysize, PIX_SRC, pw->pw_prretained, 0, 0);
  1420. X                        pw_rop(pw, 0, UNIT, xsize, ysize, PIX_SRC, NULL, 0, 0);
  1421. X                        pw_rop(pw, 0, UNIT, xsize, ysize, PIX_SRC, pr, 0, 0);
  1422. X                        pw_rop(pw, 0, 0, xsize, UNIT, CLR, NULL, 0, 0);
  1423. X                        rows++;
  1424. X                }
  1425. X        }
  1426. X        pw_batch_off(pw);
  1427. X}
  1428. X
  1429. Xcheck_rot(shape_no, xpos, ypos, newrot)
  1430. X        int     shape_no, xpos, ypos, newrot;
  1431. X{
  1432. X        int     i;
  1433. X        int     ti;             /* Bit map of i'th row    */
  1434. X        int     yi;             /* Y position on i'th row */
  1435. X        int     x0, x1, x2, x3;
  1436. X
  1437. X        x0 = xpos;
  1438. X        x1 = xpos + 1;
  1439. X        x2 = xpos + 2;
  1440. X        x3 = xpos + 3;
  1441. X        yi = ypos;
  1442. X
  1443. X        for (i = 0; i < 4; yi++, i++) {
  1444. X                if ((yi) >= 0) {
  1445. X                        ti = shape[shape_no].table[i][newrot];
  1446. X                        if (ti & 8)
  1447. X                                if ((x0 < 0) || (x0 >= UWIDTH) || (grid[x0][yi] == 1))
  1448. X                                        return FALSE;
  1449. X                        if (ti & 4)
  1450. X                                if ((x1 < 0) || (x1 >= UWIDTH) || (grid[x1][yi] == 1))
  1451. X                                        return FALSE;
  1452. X                        if (ti & 2)
  1453. X                                if ((x2 < 0) || (x2 >= UWIDTH) || (grid[x2][yi] == 1))
  1454. X                                        return FALSE;
  1455. X                        if (ti & 1)
  1456. X                                if ((x3 < 0) || (x3 >= UWIDTH) || (grid[x3][yi] == 1))
  1457. X                                        return FALSE;
  1458. X                }
  1459. X        }
  1460. X        return TRUE;
  1461. X}
  1462. END_OF_FILE
  1463. if test 7000 -ne `wc -c <'support.c'`; then
  1464.     echo shar: \"'support.c'\" unpacked with wrong size!
  1465. fi
  1466. # end of 'support.c'
  1467. fi
  1468. if test -f 'tetris.6' -a "${1}" != "-c" ; then 
  1469.   echo shar: Will not clobber existing file \"'tetris.6'\"
  1470. else
  1471. echo shar: Extracting \"'tetris.6'\" \(1579 characters\)
  1472. sed "s/^X//" >'tetris.6' <<'END_OF_FILE'
  1473. X.TH TETRIS 6 "31st March 1989"
  1474. X.SH NAME
  1475. Xtetris \- SunView block dropping game
  1476. X.SH SYNOPSIS
  1477. X.B tetris
  1478. X[
  1479. X.B "Sunview options"
  1480. X]
  1481. X.SH DESCRIPTION
  1482. X.I Tetris
  1483. Xis a game involving dropping blocks. As they drop you can move them to
  1484. Xthe left or to the right by clicking the left or right mouse buttons
  1485. Xrespectively. Pressing the shift key while clicking the button causes
  1486. Xthe falling shape to rotate anti-clockwise (left mouse button) or
  1487. Xclockwise (right mouse button). Pressing the middle mouse button causes
  1488. Xthe shape to quickly drop. Note that the mouse must be in the window in
  1489. Xwhich the shapes are dropping for these actions to work correctly.
  1490. X.PP
  1491. XPoints are scored for each block that comes to rest on the gradually
  1492. Xbuilding up pile of blocks. Different blocks in different orientations
  1493. Xhave different point values. When the pile reaches the top of the
  1494. Xscreen and no further blocks can be dropped the game ends. Whenever a
  1495. Xfull row of blocks across the screen is all completely filled in that
  1496. Xrow is removed and all the blocks above it drop down a further row.
  1497. XAs more rows are deleted the blocks drop faster.
  1498. X.PP
  1499. XA high score table is kept which is retained between separate executions
  1500. Xof the game.
  1501. X.PP
  1502. XIt looks better when run on a colour machine.
  1503. X.SH OPTIONS
  1504. X.I Tetris
  1505. Xtakes standard
  1506. X.I Sunview
  1507. Xoptions. (see 
  1508. X.I suntools (1)
  1509. X)
  1510. X.SH FILES
  1511. X.IP /usr/games/lib/tetris_scores
  1512. XTop 10 high scores.
  1513. X.SH "ENVIRONMENT VARIABLES"
  1514. X.IP TETRIS
  1515. XIf set, your desired name for the high score table.
  1516. X.SH "SEE ALSO"
  1517. X.BI suntools (1)
  1518. X.SH "BUGS"
  1519. XThe first rotation/fast-drop event in each game fails.
  1520. END_OF_FILE
  1521. if test 1579 -ne `wc -c <'tetris.6'`; then
  1522.     echo shar: \"'tetris.6'\" unpacked with wrong size!
  1523. fi
  1524. # end of 'tetris.6'
  1525. fi
  1526. if test -f 'tetris.icon' -a "${1}" != "-c" ; then 
  1527.   echo shar: Will not clobber existing file \"'tetris.icon'\"
  1528. else
  1529. echo shar: Extracting \"'tetris.icon'\" \(1933 characters\)
  1530. sed "s/^X//" >'tetris.icon' <<'END_OF_FILE'
  1531. X/* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  1532. X */
  1533. X    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x8000,0x0000,0x0000,0x0001,
  1534. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  1535. X    0x8008,0x0000,0x0000,0x1001,0x8008,0x0000,0x0000,0x1001,
  1536. X    0x8008,0x0000,0x0000,0x1001,0x8008,0x0000,0x0000,0x1001,
  1537. X    0x8008,0x0007,0x7000,0x1001,0x8008,0x000D,0xD000,0x1001,
  1538. X    0x8008,0x000B,0xB000,0x1001,0x8008,0x000E,0xE000,0x1001,
  1539. X    0x8008,0x0007,0x7000,0x1001,0x8008,0x000D,0xD000,0x1001,
  1540. X    0x8008,0x000B,0xB000,0x1001,0x8008,0x000E,0xE000,0x1001,
  1541. X    0x8008,0x8887,0x7AAA,0xB001,0x8008,0x888D,0xD555,0x5001,
  1542. X    0x800A,0x222B,0xBAAA,0xB001,0x800A,0x222E,0xE555,0x5001,
  1543. X    0x8008,0x8887,0x7AAA,0xB001,0x8008,0x888D,0xD555,0x5001,
  1544. X    0x800A,0x222B,0xBAAA,0xB001,0x800A,0x222E,0xE555,0x5001,
  1545. X    0x8008,0x8007,0x7AA8,0x9001,0x8008,0x800D,0xD552,0x3001,
  1546. X    0x800A,0x200B,0xBAA4,0x5001,0x800A,0x200E,0xE551,0x1001,
  1547. X    0x8008,0x8007,0x7AA8,0x9001,0x8008,0x800D,0xD552,0x3001,
  1548. X    0x800A,0x200B,0xBAA4,0x5001,0x800A,0x200E,0xE551,0x1001,
  1549. X    0x8008,0x8FF7,0x7AA8,0x9001,0x8008,0x8FFD,0xD552,0x3001,
  1550. X    0x800A,0x2FFB,0xBAA4,0x5001,0x800A,0x2FFE,0xE551,0x1001,
  1551. X    0x8008,0x8FF7,0x7AA8,0x9001,0x8008,0x8FFD,0xD552,0x3001,
  1552. X    0x800A,0x2FFB,0xBAA4,0x5001,0x800A,0x2FFE,0xE551,0x1001,
  1553. X    0x800F,0xFFFF,0xF888,0x9001,0x800F,0xFFFF,0xF222,0x3001,
  1554. X    0x800F,0xFFFF,0xF444,0x5001,0x800F,0xFFFF,0xF111,0x1001,
  1555. X    0x800F,0xFFFF,0xF888,0x9001,0x800F,0xFFFF,0xF222,0x3001,
  1556. X    0x800F,0xFFFF,0xF444,0x5001,0x800F,0xFFFF,0xFFFF,0xF001,
  1557. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  1558. X    0x8000,0x0000,0x0000,0x0001,0x807E,0x0018,0x0018,0x0001,
  1559. X    0x8018,0x0018,0x0000,0x0001,0x8018,0x3C7E,0x6C78,0x3C01,
  1560. X    0x8018,0x6618,0x7618,0x6601,0x8018,0x6618,0x6018,0x6001,
  1561. X    0x8018,0x7E18,0x6018,0x3C01,0x8018,0x6018,0x6018,0x0601,
  1562. X    0x8018,0x661A,0x6018,0x6601,0x8018,0x3C0C,0x6018,0x3C01,
  1563. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  1564. X    0x8000,0x0000,0x0000,0x0001,0xFFFF,0xFFFF,0xFFFF,0xFFFF
  1565. END_OF_FILE
  1566. if test 1933 -ne `wc -c <'tetris.icon'`; then
  1567.     echo shar: \"'tetris.icon'\" unpacked with wrong size!
  1568. fi
  1569. # end of 'tetris.icon'
  1570. fi
  1571. if test -f 'window.c' -a "${1}" != "-c" ; then 
  1572.   echo shar: Will not clobber existing file \"'window.c'\"
  1573. else
  1574. echo shar: Extracting \"'window.c'\" \(931 characters\)
  1575. sed "s/^X//" >'window.c' <<'END_OF_FILE'
  1576. X#include "defs.h"
  1577. X#include <sys/types.h>
  1578. X#include <sys/timeb.h>
  1579. X
  1580. Xinit_timer()
  1581. X{
  1582. X        me = (Notify_client *) & my_client_object;
  1583. X}
  1584. X
  1585. Xstart_timer()
  1586. X{
  1587. X        struct itimerval drop_time;
  1588. X        int     level;
  1589. X
  1590. X        level = 50 - (rows / 10);
  1591. X        if (level < 0)
  1592. X                level = 0;
  1593. X        drop_time.it_interval.tv_usec = 100000 + level * 2000;
  1594. X        drop_time.it_interval.tv_sec = 0;
  1595. X
  1596. X        drop_time.it_value.tv_usec = 10;
  1597. X        drop_time.it_value.tv_sec = 0;
  1598. X
  1599. X        notify_set_itimer_func(me, drop_block, ITIMER_REAL, &drop_time, ITIMER_NULL);
  1600. X}
  1601. X
  1602. Xstop_timer()
  1603. X{
  1604. X        notify_set_itimer_func(me, drop_block, ITIMER_REAL, ITIMER_NULL, ITIMER_NULL);
  1605. X}
  1606. X
  1607. Xset_events()
  1608. X{
  1609. X        window_set(canvas, WIN_CONSUME_PICK_EVENTS,
  1610. X                   WIN_NO_EVENTS, WIN_MOUSE_BUTTONS, WIN_ASCII_EVENTS, 0, 0);
  1611. X}
  1612. X
  1613. Xclear_events()
  1614. X{
  1615. X        window_set(canvas, WIN_CONSUME_PICK_EVENT,
  1616. X                   WIN_NO_EVENTS, 0);
  1617. X}
  1618. END_OF_FILE
  1619. if test 931 -ne `wc -c <'window.c'`; then
  1620.     echo shar: \"'window.c'\" unpacked with wrong size!
  1621. fi
  1622. # end of 'window.c'
  1623. fi
  1624. echo shar: End of archive 1 \(of 1\).
  1625. cp /dev/null ark1isdone
  1626. MISSING=""
  1627. for I in 1 ; do
  1628.     if test ! -f ark${I}isdone ; then
  1629.     MISSING="${MISSING} ${I}"
  1630.     fi
  1631. done
  1632. if test "${MISSING}" = "" ; then
  1633.     echo You have the archive.
  1634.     rm -f ark[1-9]isdone
  1635. else
  1636.     echo You still need to unpack the following archives:
  1637.     echo "        " ${MISSING}
  1638. fi
  1639. ##  End of shell archive.
  1640. exit 0
  1641.